package com.macro.mall.portal.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.MbrMemberVideo;
import com.macro.mall.portal.service.MbrMemberVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;

/**
 * MbrMemberVideo的路由接口服务
 * 
 * @author 
 *
 */
@Slf4j
@RestController
@RequestMapping("study")
@Api(tags = "study", description = "加入学习")
public class MbrMemberVideoController {

	/** MbrMemberVideoService服务 */
	@Autowired
	private MbrMemberVideoService mbrMemberVideoService;


    @ApiOperation("加入学习")
    @RequestMapping(value = "/studySave", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult studySave(Principal principal,@RequestBody MbrMemberVideo mbrMemberVideo) {
        if(principal==null){
            return CommonResult.unauthorized(null);
        }
        mbrMemberVideoService.saveNotNull(mbrMemberVideo);
        return CommonResult.success(null);
    }
    @ApiOperation("取消学习")
    @RequestMapping(value = "/studyDel", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult studyDel(Principal principal, @RequestBody MbrMemberVideo mbrMemberVideo) {
        if(principal==null){
            return CommonResult.unauthorized(null);
        }
        mbrMemberVideoService.deleteByMbrMemberVideo(mbrMemberVideo);
        return CommonResult.success(null);
    }




}
